﻿using Abp.Domain.Entities.Auditing;
using FutureApp.Users;
using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace FutureApp.Shop
{
    /// <summary>
    /// 商品特征属性分配值
    /// </summary>
    [Table("GoodsAttributeDistributions")]
    public class GoodsAttributeDistribution : CreationAuditedEntity<Guid, User>
    {
        /// <summary>
        /// 商品Id
        /// </summary>
        public virtual Guid GoodsId { get; set; }

        /// <summary>
        /// 商品
        /// </summary>
        [ForeignKey(nameof(GoodsId))]
        public virtual Goods Goods { get; set; }

        /// <summary>
        /// 商品特征属性值ID
        /// </summary>
        public virtual Guid AttributeValueId { get; set; }

        /// <summary>
        /// 商品特征属性值
        /// </summary>
        [ForeignKey(nameof(AttributeValueId))]
        public virtual GoodsAttributeValue AttributeValue { get; set; }

        /// <summary>
        /// 商品特征属性
        /// </summary>
        public GoodsAttribute Attribute
        {
            get { return this.AttributeValue.Attribute; }
        }

        /// <summary>
        /// 商品特征属性别名
        /// </summary>
        public virtual string AttributeAlias { get; set; }

        /// <summary>
        /// 商品特征属性值
        /// </summary>
        public string AttrValue
        {
            get { return this.AttributeValue.Value; }
        }
    }
}
